<?php
/**
 * Created by PhpStorm.
 * User: liuhong
 * Date: 2018/11/9
 * Time: 上午11:13
 */

namespace Api\Controller;


use Api\Service\LoginService;
use Api\Service\UserService;

class LoginBaseController extends BaseController
{
    public $uid;
    public $member;
    public function __construct()
    {
        //LogService::S()->writeLog('log','slog',$_POST);
        parent::__construct();
        self::checkToken();
        //dump($this->member);die;
    }

    public function checkToken(){
        $session_token=I("post.session_token");
        if(empty($session_token)){
            $this->ajax(202,'请重新登录');
        }
        //dump($session_token);die;
        $this->uid=LoginService::S()->checkTokenBackUid($session_token);
        //dump($this->uid);die;
        if(!$this->uid){
            $this->ajax(203,'token失效');
        }
        //$this->uid=2;
        if(!empty($_GET['uid'])){
            $this->uid=$_GET['uid'];
        }
        $this->member=UserService::S()->findUserInfo(array('uid'=>$this->uid));
        //dump($this->member);die;
    }

    public function memberFiled(){
        return 'grade_id,openid,mobile,realname,refer_nickname,refer_uid,nickname,headimgurl';
    }

}